<?php
session_start();
?>
<html>
<head>


<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language=javascript>
function cc()
{
	var cneed;
	var fneed;
	var crneed;
	var pneed;
	var aneed;
	var fd;
	var age=parseInt(document.getElementById("age").value);
	var foot=parseInt(document.getElementById("foot").value);
	var inch=parseInt(document.getElementById("inch").value);
	var cm1=(inch*2.54);
	var cm2=(foot*30.48);
	var cm=cm1+cm2;
	var weight=parseInt(document.getElementById("weight").value);
	var loa=document.getElementById("loa").value;
	if(document.getElementById("gen").checked)
	{
		fd=66+(13.7*weight)+(5*cm)-(6.8*age);
	}
	else
	{
		fd=655+(9.6*weight)+(1.8*cm)-(4.7*age);
	}
	switch(loa)
	{
		case "1":
			cneed=fd*1.2;
			break;
		case "2":
			cneed=fd*1.375
			break;
		case "3":
			cneed=fd*1.53;
			break;
		case "4":
			cneed=fd*1.725;
			break;
		case "5":
			cneed=fd*1.9;
			break;
			
	}
	cneed=Math.floor(cneed);
	fneed=Math.floor((cneed*0.25)/9);
	pneed=Math.floor((cneed*0.25)/4);
	crneed=Math.floor((cneed*0.25)/4);
	aneed=Math.floor((cneed*0.25)/7);	
	document.getElementById("rc").innerHTML=" "+cneed+" kcal per day";
	document.getElementById("rf").innerHTML=" "+fneed+" grams per day";
	document.getElementById("rp").innerHTML=" "+pneed+" grams per day";
	document.getElementById("rh").innerHTML=" "+crneed+" grams per day";
	document.getElementById("ra").innerHTML=" "+aneed+" grams per day";

}

function con(num)
{
	
var hc=parseInt(num.value);
var hi=hc/2.54;
var hf=Math.floor(hi/12);
var ri=Math.round(hi%12);
	if(hc>40 && hc<=210)
	{
		document.getElementById("foot").value=hf;
	}
document.getElementById("inch").value=ri;
}


function hcon()
{
	var hf=parseInt(document.getElementById("foot").value);
	var hi=parseInt(document.getElementById("inch").value);
	var hc;
	
		hc=Math.round((hf*30.48)+(hi*2.54));
		document.getElementById("cen").value=hc;
	
}

function cknum(event,num)
{
var kc;
if(window.event)
{
	kc=event.keyCode;
}
else
{
	kc=event.which;
}
var a=num.value;
if(kc==48)
{
	if(a=="")
	{
		return false;
	}
	else
	{
		return true;
	}
}  
if (kc!=8 && kc!=0)
{
	if (kc<49||kc>57)
	{
		return false;
	}
} 
}	
</script>
<!-- Script by hscripts.com -->

<style type="text/css">
<!--
.style11 {
	color: #0000FF;
	font-weight: bold;
	font-size: large;
}
body {
	background-color: #FFFFFF;
}
#Layer1 {
	position:absolute;
	left:118px;
	top:3px;
	width:296px;
	height:33px;
	z-index:1;
}
.style12 {
	color: #660099;
	font-weight: bold;
}
-->
</style>
</head>

<body>



<div id="Layer1"><span class="style11">CALORIE CALCULATOR</span></div>
<form>

  <p>&nbsp;</p>
  <table width="327" align="center">
 <tr><td width="96" align="right">&nbsp;</td>
<td width="219">&nbsp;</td>
 </tr>                     
<tr>
  <td width="96" align="right"><div align="right"><strong>Age:</strong></div></td>
  <td width="219"><strong>
  <input type="text" name="age" id="age" align="left" size="3" maxlength="2" onKeyPress="return cknum(event,age)">
  years</strong></td>
</tr>
<tr ><td align="right"><div align="right"><strong>Gender:</strong></div></td>
<td align="left"><strong>
  <input type="radio" name="gen" id="gen"  checked>
  Male
    <input type="radio" name="gen" id="gen">
    Female</strong></td>
</tr>
<tr ><td align="right"><div align="right"><strong>Height</strong>:</div></td>
<td>
<strong>
<select name="foot" id="foot" onChange="hcon()">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
</select>
Foot</strong>
<select name="inch" id="inch" onChange="hcon()"><script type="text/javascript">
for(i=0;i<12;i++)
{ 
document.write("<option value=" + i +">"+ i +"</option>");
}
</script>
</select>
<strong>Inches 
<input type="text" name="cen" id="cen" size="4" onKeyUp="con(cen)">
cm</strong></td>
</tr>
<tr><td align="right"><div align="right"><strong>Weight:</strong></div></td>
<td><strong>
  <input type="text" name="weight" id="weight" maxlength="3" size="3" onKeyPress="return cknum(event,weight)">
  Kg</strong></td>
</tr>
<tr><td align="right"><div align="right"><strong>Activeness:</strong></div></td>
<td>
  <strong>
<select name="loa" id="loa">
  <option value="1">Sedentary</option>
  <option value="2">Light Active</option>
  <option value="3">Moderately Active</option>
  <option value="4">Very Active</option>
  <option value="5">Extra Active</option>
</select>
</tdv>
  </strong></tr>
<tr><td colspan="2" align="center"><input type="button" value="Calculate Calorie Needs" onClick="cc()">
  <input name="btn" type="reset" value="Reset"></td>
</tr>
</table>
</form>


<br>
<table align="center">
<tr>
  <td width="158" align="right"><span class="style12">YOU NEED</span> 
    <div align="center"></div></td>
<td width="263"><div id="rc"></div></td></tr>
<tr><td align="right" bordercolor="#CCCCCC" bgcolor="#FFFFFF"><div align="right"><strong>To maintain your  </strong></div></td>
<td align="left" bordercolor="#CCCCCC" bgcolor="#FFFFFF"><strong> calorie intake, you need : </strong></td>
</tr>
<tr><td align="right"><div align="center"><strong>Fat</strong></div></td>
<td><div id="rf"></div></td></tr>
<tr><td align="right"><div align="center"><strong>Protein</strong></div></td>
<td><div id="rp"></div></td></tr>
<tr><td align="right"><div align="center"><strong>Carbohydrate</strong></div></td>
<td><div id="rh"></div></td></tr>
<tr><td align="right"><div align="center"><strong>Alcohol</strong></div></td>
<td><div id="ra"></div></td></tr>
</table>



</body>
</html>
